import at.guigu.pojo.Brand;
import at.guigu.service.BrandService;
import org.junit.Test;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class InquireTwo {
    //1 创建一个私有的BrandService对象
    private BrandService brandService = new BrandService();

    // 动态单条件查询——对象参数接收
    @Test
    public void getBySingleConTwo() {
        String companyName = "华为";
        companyName = "%" + companyName + "%";
        Brand brand = new Brand();
        brand.setCompanyName(companyName);
        List<Brand> brands= brandService.selectBySingleConTwo(brand);
        System.out.println(brands);
    }
    // 动态单条件查询——Map集合参数接收
    @Test
    public void getBySingleConTwoo() {
        String companyName = "华为";
        companyName = "%" + companyName + "%";
        Map map = new HashMap();
        map.put("companyName", companyName);
        List<Brand> brands= brandService.selectBySingleConTwoo(map);
        System.out.println(brands);
    }
/*---------------------------------------------------------------------------------------*/
    // 动态多条件查询——对象参数接收
    @Test
    public void getByMaxConOne() throws IOException {
        //2 模拟接收前端传回的多条件参数并进行参数处理
        int status = 1;
        String companyName = "华为";
        String brandName = "华为";
        companyName = "%" + companyName + "%";
        brandName = "%" + brandName + "%";
        //3 将多条件参数封装到对象中
        Brand brand = new Brand();
        brand.setStatus(status);
        brand.setCompanyName(companyName);
        brand.setBrandName(brandName);

        List<Brand> brands= brandService.selectByMaxConOne(brand);
        System.out.println(brands);
    }
    // 动态多条件查询——Map集合参数接收
    @Test
    public void getByMaxConTwo() throws IOException {
        //2 模拟接收前端传回的多条件参数并进行参数处理
        int status = 1;
        String companyName = "华为";
        String brandName = "华为";
        companyName = "%" + companyName + "%";
        brandName = "%" + brandName + "%";
        //3 将多条件参数封装到对象中
        Map map = new HashMap();
        map.put("status", status);
        map.put("companyName", companyName);
        map.put("brandName", brandName);

        List<Brand> brands= brandService.selectByMaxConTwo(map);
        System.out.println(brands);
    }
}
